home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
util
/
cdity
/
IFX.lha
/
IFX
/
AmigaE
/
ifx.e
< prev
next >
Wrap
Text File
|
1998-01-02
|
36KB
|
1,577 lines
->
-> IFX
->
-> © by Dobes Vandermeer, 1997
->
-> Events daemon
->
-> Standard modules
MODULE 'dos/dos', 'dos/dosextens', 'dos/dostags'
MODULE 'exec/ports', 'exec/libraries',
'exec/tasks', 'exec/nodes', 'exec/io',
'exec/interrupts', 'exec/semaphores', 'exec/memory'
MODULE 'intuition/intuition'
MODULE 'utility'
MODULE 'libraries/commodities'
MODULE 'timer'
MODULE 'layers', 'graphics/clip'
MODULE 'devices/input', 'devices/inputevent', 'devices/timer'
MODULE 'workbench/startup', 'workbench/workbench'
MODULE 'icon'
-> Special modules
MODULE '*modules/action', '*modules/ifx'
MODULE '*patch'
MODULE '*input/inputhandler'
MODULE 'tools/cli'
MODULE 'other/ecodex', 'other/split'
MODULE 'fabio/rxobj_oo'
MODULE 'fabio/cxobj_oo'
MODULE 'tools/sound'
MODULE 'amigalib/tasks'
MODULE 'dos/dostags'
MODULE '*speak/speak'
MODULE 'tools/detatch'
->
-> CONSTANTS
->
CONST IFX_VERSION=2, IFX_REVISION=5
CONST NAMESIZE=256
->
-> Global objects
->
-> Ports and lists
DEF rx:PTR TO rxobj
DEF cx:PTR TO cxobj
DEF mp:PTR TO mp
DEF ids:PTR TO ifx_id
DEF tasks:PTR TO ifx_task
-> Input Handler
DEF inputhandler:PTR TO inputhandler
-> Global flags
DEF enabled, on_hour, do_chime, program_done
-> Sounds
DEF sounds:PTR TO LONG, curr_snd
-> Signals
DEF sigs:LONG, soundsigs:LONG
-> Current directory
DEF currentdir:LONG, olddir:LONG
-> Patches
DEF p_ow:PTR TO patch, p_owt:PTR TO patch, p_cw:PTR TO patch,
p_os:PTR TO patch, p_ost:PTR TO patch, p_cs:PTR TO patch,
p_db:PTR TO patch, p_msz:PTR TO patch
-> Semaphore
DEF ids_sem:PTR TO ss
->
-> MAIN
->
PROC main() HANDLE
-> Error messages
DEF err:PTR TO CHAR, more:PTR TO CHAR
-> Signal processing
DEF gotsigs
-> Message port
DEF msg:PTR TO ifx_msg
-> Misc.
DEF temp
-> Clock chimes
DEF timerio:PTR TO timerequest, timermp:PTR TO mp
-> Detatch!
detatch('IFXII')
->
-> Initialize global variables
->
-> This should be done FIRST to avoid errors!
->
ids := NIL
sigs := soundsigs := NIL
enabled := 1 -> We are active by DEFault
NEW sounds[2]
currentdir := olddir := NIL
curr_snd := 1
->
-> Only add the port if it isn't already added
->
->>>
->>>>>>> FORBID
Forbid()
IF mp := FindPort('IFX')
->
-> If it is, tell us to QUIT.
->
->
-> We'll send a EXEC message
->
NEW msg
msg.cmd := IFX_QUIT
msg.length := SIZEOF ifx_msg
PutMsg(mp, msg)
->
-> Wait long enough for (the other) IFX to quit.
->
Delay(50)
->
-> De-allocate the msg
->
END msg
msg := NIL
mp := NIL
ENDIF
->
-> Prepare exec mp (NEEDED by patches)
->
mp := CreateMsgPort()
IF mp=NIL
Permit()
Throw("INIT", "MP")
ENDIF
mp.ln.pri := 50
mp.ln.name:= 'IFX'
sigs := sigs OR Shl(1, mp.sigbit)
AddPort(mp)
->>>
->>>>>>> PERMIT
Permit()
->->WriteF('mp: \h (\h)\n', sigs, Shl(1, mp.sigbit))
->>
->>>> LIBRARIES & DEVICES
->>
->
-> Open Layers Library
->
layersbase := OpenLibrary('layers.library', 36)
IF layersbase=NIL THEN Throw("INIT", "LAYR")
->
-> Open Utility Library
->
utilitybase := OpenLibrary('utility.library', 36)
IF utilitybase=NIL THEN Throw("INIT", "UTIL")
->
-> Open input.device
->
NEW inputhandler.init({inputhandlerfunc}, NIL, 25, 'IFX Input Handler')
->
-> Open timer.device
->
timermp := CreateMsgPort()
IF timermp=NIL THEN Throw("INIT", "TiMP")
timerio := CreateIORequest(timermp, SIZEOF timerequest)
IF timerio=NIL THEN Throw("INIT", "TiIO")
IF OpenDevice('timer.device', UNIT_WAITUNTIL, timerio, NIL) THEN Throw("INIT", "TiOp")
timerbase := timerio.io.device
timerio.io.mn.ln.type := NIL -> This should prevent crashes
sigs := sigs OR Shl(1, timermp.sigbit)
->->WriteF('timer: \h (\h)\n', sigs, Shl(1, timermp.sigbit))
->
-> Get command line settings
->
do_wbargs()
->
-> Load configuration data
->
load_config('S:IFX.ids')
->
-> Prepare patches
->
NEW p_ow.init( intuitionbase, -204, {new_ow}, TRUE)
NEW p_owt.init(intuitionbase, -606, {new_owt}, TRUE)
NEW p_cw.init( intuitionbase, -72, {new_cw}, TRUE)
NEW p_os.init( intuitionbase, -198, {new_os}, TRUE)
NEW p_ost.init(intuitionbase, -612, {new_ost}, TRUE)
NEW p_cs.init( intuitionbase, -66, {new_cs}, TRUE)
NEW p_db.init( intuitionbase, -96, {new_db}, TRUE)
NEW p_msz.init(layersbase, -180, {new_msz}, TRUE)
->>
->>>> FORBID
Forbid()
->
-> Install patches
->
p_ow.install()
p_owt.install()
p_cw.install()
p_os.install()
p_ost.install()
p_cs.install()
p_db.install()
p_msz.install()
->
-> Set up first timer event
->
-> The timer.device was opened earlier.
->
settimer(timerio)
Permit()
->>>> PERMIT
->>
->
-> Install input handler
->
-> The input.device was opened earlier
->
inputhandler.install()
->
-> Prepare commodities object
->
NEW cx.cxobj()
cx.create('IFX', 'IFX II © by Dobes Vandermeer', 'Input effects (FX) Daemon')
sigs := sigs OR cx.signal()
->->WriteF('cx: \h (\h)\n', sigs, cx.signal())
->
-> Prepare AREXX object
->
NEW rx.rxobj('PLAY')
sigs := sigs OR rx.signal()
->
-> Prepare Semaphore
->
NEW ids_sem
InitSemaphore(ids_sem)
->
-> Break handling
->
sigs := sigs OR SIGBREAKF_CTRL_C
-> Main Loop
program_done := FALSE
gotsigs := CheckSignal(sigs)
WHILE program_done=FALSE
->
-> Check for a timer event
->
IF (gotsigs AND Shl(1, timermp.sigbit))<>NIL
WaitIO(timerio) -> Get the event
IF on_hour
do_effect('hourly_chime')
ELSE
do_effect('quarterly_chime')
ENDIF
settimer(timerio)
ENDIF
->
-> Check for a message (probably from a patch)
->
IF (gotsigs AND Shl(1, mp.sigbit))<>NIL
WHILE (msg := GetMsg(mp))<>NIL
temp := msg.cmd
SELECT temp
CASE -1 -> One of our patches
IF checktask(msg.data)=FALSE
do_effect(msg.id)
ENDIF
FreeMem(msg, msg.length) -> Free it for them
CASE IFX_ID
IF msg.id THEN do_effect(msg.id)
IF msg.replyport THEN ReplyMsg(msg)
CASE IFX_EDIT_IDS
msg.data := ids
IF msg.replyport THEN ReplyMsg(msg)
CASE IFX_EDIT_TASKS
msg.data := tasks
IF msg.replyport THEN ReplyMsg(msg)
CASE IFX_EDIT_SEM
msg.data := ids_sem
IF msg.replyport THEN ReplyMsg(msg)
CASE IFX_ACTION
IF msg.data THEN do_action(msg.data)
IF msg.replyport THEN ReplyMsg(msg)
CASE IFX_EFFECT
IF msg.data THEN do_effect(msg.data)
IF msg.replyport THEN ReplyMsg(msg)
CASE IFX_CHIMES
IF msg.data
do_chime := 1
ELSE
do_chime := 0
ENDIF
IF msg.replyport THEN ReplyMsg(msg)
CASE IFX_PARSE
IF msg.data
ifx_parse(msg.data)
ENDIF
CASE IFX_QUIT
IF msg.replyport THEN ReplyMsg(msg)
do_effect('ifx_kill')
program_done := TRUE
DEFAULT
IF msg.replypor